<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<script>
function menu1(){
	
		var uid=$(":checkbox[name=member]:checked").val();
		var lv=$(":radio[name=level]:checked").val();
			
			if(uid==undefined){
				alert("아이디를 선택하세요 !");
				return;
			}else if(lv==undefined){
				alert("레벨을 선택하세요 !");
				return;
			}
		
		location.href="admin.do?mode=lvChange&uid="+uid+"&lv="+lv;
}

function menu2(){
	var uid = $(":checkbox[name=member]:checked").val();
	
	if (uid == undefined) {
		alert("아이디를 선택하세요 !");
		
		return;
	}
location.href = "admin.do?mode=leave&uId=" + uid;
alert("탈퇴성공!");
}




$(function() {
	$("#find").click(function() {
		var nickNameTxt = $("#nickNameTxt").val();
		if(nickNameTxt==""){
			alert("아이디를 입력하세요.");
			return;
			}
		
		$.ajax({
			type:"POST",
			url:"admin.do",
			data:"mode=findMemberList&nickName="+nickNameTxt,
			dataType:"json",
			success:function(jsonData){
				
				var mvo=jsonData.mvo;
				//alert(mvo);
				var str = "";	
				if(mvo!=""){	
					var str = "";
					str+="<div align='center'>";
					str+="<input type='radio' name='level' value='0'>일반회원";
					str+="<input type='radio' name='level' value='99'>관리자";
					str+="<input type='button' value='수정하기'  onclick='menu1()'>";
					str+="<input type='button' value='탈퇴' onclick='menu2()'>";
					str+="</div>";
					str+="<table border='1'>";
					str+="<tr>";
					str+="<td>선택</td>";
					str+="<td>아이디</td>";
					str+="<td>닉네임</td>";
					str+="<td>레벨</td>";
					str+="</tr>";
					for(i=0;i<mvo.length;i++){
						str+="<tr>";	
						str+="<td><input type='checkbox' name='member' value="+mvo[i].uId+"></td>";
						str+="<td><a href='member.do?mode=friendMain&uid="+mvo[i].uId+"'>"+mvo[i].id+"</a></td>";
						str+="<td>"+mvo[i].nickname+"</td>";						
						var lv=""
						if(mvo[i].level==0){
							lv="일반회원";
						}else{
							lv="관리자";
						}		
						str+="<td>"+lv+"</td>";
						str+="</tr>";
						
					}
					str+="</table>";
					
				}else{
					str="찾는 회원이 없습니다!";
				
				}						
				$("#result").html(str);
				}
			});
		});	
	});
</script>

<h2>회원 정보 검색</h2>
    		<p>
    			<input type="text" id="nickNameTxt" >
    			<input type="button" value="검색" id="find">
    			<div id="result"></div>
    		</p> 
